www.gusucode.com > VC++ 多种窗体动画特效源码-源码程序 > VC++ 多种窗体动画特效源码-源码程序/code/MainFrm.cpp

    // MainFrm.cpp : implementation of the CMainFrame class
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "TabWnd.h"

#include "MainFrm.h"
#include "TreeViewClass.h"
#include "TreeViewFile.h"
#include "TreeViewResource.h"
#include "StatusBarMsgWnd.h"
#include "windowmagicdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_ANIMATE, OnAnimate)
	ON_COMMAND(ID_MESSAGE, OnMessage)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	pDialog = NULL;
}

CMainFrame::~CMainFrame()
{
	if(pDialog!=NULL)
		delete pDialog;
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	// Create the image list to be used with the control bars.
	m_ImageList.Create(IDB_IMAGELIST, 13, 1, RGB(0,255,0));

	// CG: The following block was inserted by the 'Dialog Bar' component
	{
		m_wndWorkspace.SetBtnImageList (&m_ImageList);
		m_wndWorkspace.SetMenuID(IDR_POPUP);

		// Initialize dialog bar m_wndWorkspace
		if (!m_wndWorkspace.Create(this, CG_ID_VIEW_WORKSPACE,
			_T("Workspace"), CSize(220,200)))
		{
			TRACE0("Failed to create dialog bar m_wndWorkspace\n");
			return -1;		// fail to create
		}

		// Add the views to the tab control.
		m_wndWorkspace.AddView(_T("Class"),    RUNTIME_CLASS(CTreeViewClass));
		m_wndWorkspace.AddView(_T("Resource"), RUNTIME_CLASS(CTreeViewResource));
		m_wndWorkspace.AddView(_T("Files"),    RUNTIME_CLASS(CTreeViewFile));

		// Define the image list to use with the tab control
		m_TabImages.Create (IDB_IL_TAB, 16, 1, RGB(0,255,0));
		m_wndWorkspace.SetTabImageList(&m_TabImages);
	    // allow bar to be resized when floating
	    m_wndWorkspace.SetBarStyle(m_wndWorkspace.GetBarStyle() |
		    CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

		m_wndWorkspace.EnableDocking(CBRS_ALIGN_ANY);
		EnableDocking(CBRS_ALIGN_ANY);
		DockControlBar(&m_wndWorkspace, AFX_IDW_DOCKBAR_LEFT);
	}
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CMDIFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CMDIFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


void CMainFrame::OnAnimate() 
{
	// TODO: Add your command handler code here
   pDialog = new CWindowMagicDlg();
   //Check if new succeeded and we got a valid pointer to a dialog object
   if(pDialog != NULL)
   {
      BOOL ret = pDialog->Create(IDD_WINDOWMAGIC_DIALOG,this);
      if(!ret)   //Create failed.
         AfxMessageBox("Error creating Dialog");
      pDialog->ShowWindow(SW_SHOW);
   }
}

void CMainFrame::OnMessage() 
{
	// TODO: Add your command handler code here
    CStatusBarMsgWnd* t_MsgWnd = CStatusBarMsgWnd::CreateObject(
                                                       _T("谢谢您的使用,欢迎多提意见 !!"), 
                                                        180, 
                                                        150, 
                                                        4000, 
                                                        10,
                                                        CRect(30, 30, 130, 110),
                                                       this);

	t_MsgWnd->PopMsg();
	
}